package com.ansion.commonchat.startup.fresco.fetcher;

import androidx.annotation.IntDef;

import com.facebook.imagepipeline.producers.FetchState;
import com.facebook.imagepipeline.producers.NetworkFetcher;
import com.facebook.imagepipeline.request.ImageRequest;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * Description:
 * <p>
 * Created by ____lamer on 2019-11-28 13:52
 */
public interface IFrescoFetcher<FETCH_STATE extends FetchState> extends NetworkFetcher<FETCH_STATE> {

    int ORDER_SOFT_DNS = 10000;
    int ORDER_PDF = ORDER_SOFT_DNS - 1;

    /**
     * 降序，越小越先执行，而且不能重复
     *
     * @return order
     */
    @Key
    int order();

    /**
     * 是否拦截这个fetcher
     *
     * @param request 请求的描述
     * @return true表示可以处理这个request，将不会分发给其他的fetcher，会执行N次，不能耗时操作
     */
    boolean interrupt(ImageRequest request);

    @IntDef({
            ORDER_SOFT_DNS,
            ORDER_PDF,
    })
    @Retention(RetentionPolicy.SOURCE)
    @interface Key {

    }
}
